package moni.anyou.com.view.view;

import android.annotation.TargetApi;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.readystatesoftware.systembartint.SystemBarTintManager;

import moni.anyou.com.view.R;
import moni.anyou.com.view.base.BaseActivity;

public class TestFragementActivity extends BaseActivity {





    private FrameLayout fragmentLayout;
    private LinearLayout bottomLayout;

    //手机高版本样式
    private void initState() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }

    }

    private SystemBarTintManager tintManager;
    //手机高版本样式
    @TargetApi(19)
    private void initWindow() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            tintManager = new SystemBarTintManager(this);
            tintManager.setStatusBarTintColor(R.color.newappcolor);
            tintManager.setStatusBarTintEnabled(true);
        }
    }



    private KindergartenFragment kindergartenFragment;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initState();
        initWindow();
        requestWindowFeature(Window.FEATURE_NO_TITLE);
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
//        getWindow().addFlags(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); //隐藏状态栏
        setContentView(R.layout.activity_markmain_index);
        fragmentLayout=(FrameLayout)findViewById(R.id.fragment_layout);
        bottomLayout = (LinearLayout)findViewById(R.id.ll_bottom);
        kindergartenFragment=new KindergartenFragment();
        getSupportFragmentManager().beginTransaction()
                .add(fragmentLayout.getId(),kindergartenFragment)
                .show(kindergartenFragment).commitNowAllowingStateLoss();


//        Toast.makeText()


//        /**针对底部有软菜单的手机*/
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) bottomLayout.getLayoutParams();
        lp.setMargins(0,0,0,getNavigationBarHeight());
//        Toast.makeText(this,"123",Toast.LENGTH_LONG).show();
    }

    /**获取底部软键盘状态栏的高度 适配这种类型的手机*/

    public int getNavigationBarHeight() {
        Resources resources = this.getResources();
        int resourceId=resources.getIdentifier("navigation_bar_height","dimen","android");
        int height = resources.getDimensionPixelSize(resourceId);
        Log.v("navigation bar>>>", "height:" + height);
        return height;

    }
}
